import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/im_entity.dart';

ImEntity $ImEntityFromJson(Map<String, dynamic> json) {
  final ImEntity imEntity = ImEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    imEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    imEntity.msg = msg;
  }
  final List<ImData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ImData>(e) as ImData).toList();
  if (data != null) {
    imEntity.data = data;
  }
  return imEntity;
}

Map<String, dynamic> $ImEntityToJson(ImEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension ImEntityExtension on ImEntity {
  ImEntity copyWith({
    int? code,
    String? msg,
    List<ImData>? data,
  }) {
    return ImEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

ImData $ImDataFromJson(Map<String, dynamic> json) {
  final ImData imData = ImData();
  final String? account = jsonConvert.convert<String>(json['account']);
  if (account != null) {
    imData.account = account;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    imData.nickname = nickname;
  }
  final String? photo = jsonConvert.convert<String>(json['photo']);
  if (photo != null) {
    imData.photo = photo;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    imData.msg = msg;
  }
  final String? lastTime = jsonConvert.convert<String>(json['last_time']);
  if (lastTime != null) {
    imData.lastTime = lastTime;
  }
  final String? unread = jsonConvert.convert<String>(json['unread']);
  if (unread != null) {
    imData.unread = unread;
  }
  return imData;
}

Map<String, dynamic> $ImDataToJson(ImData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['account'] = entity.account;
  data['nickname'] = entity.nickname;
  data['photo'] = entity.photo;
  data['msg'] = entity.msg;
  data['last_time'] = entity.lastTime;
  data['unread'] = entity.unread;
  return data;
}

extension ImDataExtension on ImData {
  ImData copyWith({
    String? account,
    String? nickname,
    String? photo,
    String? msg,
    String? lastTime,
    String? unread,
  }) {
    return ImData()
      ..account = account ?? this.account
      ..nickname = nickname ?? this.nickname
      ..photo = photo ?? this.photo
      ..msg = msg ?? this.msg
      ..lastTime = lastTime ?? this.lastTime
      ..unread = unread ?? this.unread;
  }
}